<?php

namespace App\Trip\Orders\BookOrders\Params;

use App\Trip\Enums\OrderBusiness;
use App\Trip\Enums\TripTypes;
use App\Trip\Orders\BookOrders\Params\AbstractOrderParam\AbstractSnapOrdersParam;

class SnapOrdersParam extends AbstractSnapOrdersParam
{


    private SnapParam $snapParam;

    public function __construct(array $param, ?SnapParam $snapParam = null)
    {
        $this->setOrders($param);
        $this->setTripId(generate_order_id(TripTypes::TRAIN, OrderBusiness::SNAP));
        $this->snapParam = $snapParam;
        $this->injectSnapParam();
    }

    private function injectSnapParam()
    {
        foreach ($this->orders_data as $key => $order_data) {
            $this->orders_data[$key]['snap_param'] = $this->snapParam;
        }
    }

    public function getOrders(): array
    {
        return $this->dealOrders($this->orders_data, 'App\Trip\Orders\BookOrders\Params\SnapOrderParam');
    }

    public function getSnapParam(): SnapParam
    {
        return $this->snapParam;
    }
}